package artid.com.arttogo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import artid.com.arttogo.R;
import artid.com.arttogo.bean.CategoryList;
import artid.com.arttogo.task.CallbackSky;

public class ListAdapter extends BaseAdapter {
	LayoutInflater mInflater;
	ViewHolder holder;
	CallbackSky cs;
	private List<CategoryList> list;

	public ListAdapter(Context mContext, List<CategoryList> list) {
		mInflater = LayoutInflater.from(mContext);
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder vh = null;
		if (convertView == null) {
			vh = new ViewHolder();
			convertView = mInflater.inflate(R.layout.listview_item, null);
			vh.text = (TextView) convertView.findViewById(R.id.tv_text);
			convertView.setTag(vh);
		} else {
			vh = (ViewHolder) convertView.getTag();
		}
		CategoryList ca = list.get(position);
		vh.text.setText(ca.getTitle());
		return convertView;
	}

	class ViewHolder {
		TextView text;
	}
}
